#include <iostream>
using namespace std;


class Complex
{
public:
    Complex(double r=0,double i=0):re(r),im(i) {}

    void print() const
    {
        cout<< re <<" + " << im <<"i\n";
    }
   
    friend Complex operator+( const Complex&  cm1, const Complex& cm2); //+    

private:
    double re;
    double im; 
};
Complex operator+(const Complex&  cm1,const Complex&  cm2) //+ 
{
        Complex cm;
        cm.re = cm1.re + cm2.re;
        cm.im = cm1.im + cm2.im;
        return cm;
}

int main()
{
    Complex cm1(1,2), cm2;
    cm2=3 + cm1;
    //cm2=cm1+3;
    cm2.print();
    return 0;
}


/*
class Complex
{
public:
    //explicit
    Complex(double r=0,double i=0):re(r),im(i) {}

    void print() const
    {
        cout<< re <<" + " << im <<"i\n";
    }

   Complex operator+( const Complex& cm2)
   {
       return Complex(re + cm2.re,im + cm2.im);
   }   

private:
    double re;
    double im; 
};


int main()
{
    Complex cm1(1,2), cm2;
    cm2= 3 + cm1;
    //cm2=cm1+3;
    cm2.print();
    return 0;
}
*/